package com.example.demo.design.strategy_pattern;

/**
 * @Author: liull
 * @Description: 电影票类，充当策略模式的context
 * @Date: Created in 18:02 2020/11/18
 * @Modified By:
 */
public class MovieTicket {
    /** 持有一个Discount的引用，实现策略模式的关键所在 */
    private Discount discount;

    /** 原始票价价格 */
    private double price;

    public void setDiscount(Discount discount) {
        this.discount = discount;
    }

    public double getPrice() {
        return discount.calculate(price);
    }

    public void setPrice(double price) {
        this.price = price;
    }
}
